home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 645 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.6 KB

  1. Path: chronicle.mti.sgi.com!austern
  2. From: James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de>
  3. Newsgroups: comp.std.c++
  4. Subject: Re: Single-line comment and line continuation
  5. Date: 06 Mar 1996 09:43:54 PST
  6. Organization: -
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <9603061601.AA10111@lts.sel.alcatel.de>
  9. References: <313B3175.331A@strata3d.com> <4hffkm$3f0@engnews1.Eng.Sun.COM> <4hgbpd$1pl@cnn.Princeton.EDU>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: Wed, 6 Mar 96 17:01:52 +0100
  12. In-Reply-To: tim@franck.Princeton.EDU's message of 05 Mar 1996 09:41:20 PST
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMT3O7ky4NqrwXLNJAQG0sQH+LV5EzJRem5DERtzTm0ey5vZXv+hK85bv
  15.     SDTixG5490jIOQYm/FFET6flNMWNIXg0ttSi8D2TPMd/mmxNE2xpmg==
  16.     =w+ad
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. In article <4hgbpd$1pl@cnn.Princeton.EDU> tim@franck.Princeton.EDU
  20. (Tim Hollebeek) writes:
  21.  
  22. |> Steve Clamage (clamage@Eng.Sun.COM) wrote:
  23. |> : >I just ran across something in my C++ compiler dealing with single line 
  24. |> : >comments and the line continuation token:
  25. |> : >
  26. |> : > if ((ch[0] == '\\') && (ch[1] == '\\'))  //look for initial \\
  27. |> : >
  28. |> : >This, under my compiler implementation will choke because of the line 
  29. |> : >continuation token, '\' at the end of the comment.
  30.  
  31. |> : In C++, simply don't use '//' comments on any line that ends with an
  32. |> : escaped newline (including macro definitions!). In your example, it would
  33. |> : make the comment more readable IMHO if you put the '\\' in quotes anyway,
  34. |> : and would eliminate the problem.
  35.  
  36. |> Or simply add a single space after the last \, and take advantage of
  37. |> that annoying behavior for once :-)
  38.  
  39. This will probably work on most Unix implementations, but it is not
  40. guaranteed.  An implementation is allowed to ignore trailing
  41. whitespace when reading in the file.  (This is to facilitate coding in
  42. environments with fixed length records, where the system always pads
  43. your line of code with blanks to make it the fixed length.)
  44.  
  45. --
  46. James Kanze         Tel.: (+33) 88 14 49 00        email: kanze@gabi-soft.fr
  47. GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
  48. Conseils, itudes et rialisations en logiciel orienti objet --
  49.                 -- A la recherche d'une activiti dans une region francophone
  50. ---
  51. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  52.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  53.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  54.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  55.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  56. ]
  57.